package org.mineground.commands.player;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.mineground.Main;
import org.mineground.PermissionNodes;
import org.mineground.player.MinegroundPlayer;

public class PvP implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) throws CommandException {
	Player player = (Player) sender;
        
        if (!player.hasPermission(PermissionNodes.PERMISSION_PVP_COMMAND)) {
            return true;
        }
        
        String action;
        
        MinegroundPlayer playerInstance = Main.getInstance().getPlayer(player);
        
        if (playerInstance.getPvPToggle()) {
            playerInstance.setPvPToggle(false);
            action = "disabled";
        }
        
        else {
            playerInstance.setPvPToggle(true);
            action = "enabled";
        }
        
        player.sendMessage(ChatColor.DARK_GREEN + "Your PvP has been " + action);
	return true;
    }
}
